home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4680 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: simple code, argc, argv, strcmp()
  5. Date: Tue, 06 Feb 96 14:04:25 GMT
  6. Organization: none
  7. Message-ID: <823615465snz@genesis.demon.co.uk>
  8. References: <11f7cc$17261a.3b3@daprez> <4etj7c$bma@news.iag.net> <fcusack-0202961621470001@mudskipper.cac.psu.edu> <4f0rjn$sfh@news.iag.net>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4f0rjn$sfh@news.iag.net> jatmon@iag.net "John R Buchan" writes:
  15.  
  16. >You are correct, of course.  Stupidity on my part. I tend to get careless 
  17. >about strcmp's reverse logic (ie returns False, when the strings match), when
  18. >I am not paying attention (not an excuse, just an explanation).  I normally 
  19. >compare the return value to 0, just to keep myself straight.  
  20.  
  21.  
  22. That's the point though - strcmp() simply doesn't return a boolean value so
  23. saying 'ie returns False' is just plain wrong and is what gets you into
  24. trouble. strcmp() is in some sense more like a difference operation. e.g.
  25. (ignoring overflow) if you take 2 integers a and b and calculate a-b the
  26. result is >0 if a is larger, ==0 if they are equal and <0 if a is smaller,
  27. just as strcmp(sa,sb) is defined. IMHO the definition of strcmp is quite
  28. natural (but maybe the name doesn't quite reflect that definition).
  29.  
  30. -- 
  31. -----------------------------------------
  32. Lawrence Kirby | fred@genesis.demon.co.uk
  33. Wilts, England | 70734.126@compuserve.com
  34. -----------------------------------------
  35.